package cn.mapper;

import cn.entity.Examine;
import cn.entity.ExamineCondition;
import org.springframework.util.StringUtils;

public class ExamineProvider {

    public String selectPage(ExamineCondition condition){
        StringBuilder sb = new StringBuilder();
        sb.append("select ex.*,so.`name` company_name,su.name check_name FROM examine ex left join sys_office so on ex.id=so.id LEFT join sys_user su on ex.examine_user_id = su.id where ex.del_flag = 0 ");
        if (!StringUtils.isEmpty(condition.getRealName())){
            sb.append("and su.name like concat('%',#{realName},'%')");
        }
        if (!StringUtils.isEmpty(condition.getCompanyName()) ){
            if (!condition.getCompanyName().equals("全部")){
                sb.append(" and so.name =#{companyName}");
            }
        }
        if (!StringUtils.isEmpty(condition.getType())){
            if (condition.getType()!=0) {
                sb.append(" and ex.type =#{type}");
            }
        }
        return sb.toString();
    }
}
